﻿using System;
namespace Moonlite.Services.CodeCompletion
{
    public class AndromedaSource : AndromedaObjectWithSpecificChildren, IAndromedaObjectWithName, IAndromedaObjectWithImageIndex
    {
        private int tagLength;
        public int TagLength
        {
            get { return tagLength; }
            internal set { tagLength = value; }
        }
        private AndromedaSourceCollection includedSources = new AndromedaSourceCollection();
        public AndromedaSourceCollection IncludedSources
        {
            get { return includedSources; }
        }
        public int ImageIndex { get { return AndromedaImageIndexes.ImageIndexGeneratedFile; } }
        public string Name { get; set; }
        public AndromedaSourceType Type { get; set; }
        public int InclusionType { get; set; }
        public string Path { get; set; }
        public AndromedaSource()
            : this("", AndromedaSourceType.File, 0, "")
        {
        }

        public override AndromedaObjectCollection GetAllChildren()
        {
            AndromedaObjectCollection children = new AndromedaObjectCollection();
            children.AddRange(base.GetAllChildren());
            foreach (AndromedaSource includedSource in includedSources)
            {
                children.AddRange(includedSource.GetAllChildren());
            }
            return children;
        }

        public override AndromedaObjectClassCollection GetAllClasses()
        {
            AndromedaObjectClassCollection children = new AndromedaObjectClassCollection();
            children.AddRange(base.GetAllClasses());
            foreach (AndromedaSource includedSource in includedSources)
            {
                children.AddRange(includedSource.GetAllClasses());
            }
            return children;
        }

        public override AndromedaObjectEnrichmentCollection GetAllEnrichments()
        {
            AndromedaObjectEnrichmentCollection children = new AndromedaObjectEnrichmentCollection();
            children.AddRange(base.GetAllEnrichments());
            foreach (AndromedaSource includedSource in includedSources)
            {
                children.AddRange(includedSource.GetAllEnrichments());
            }
            return children;
        }

        public override AndromedaObjectFieldCollection GetAllFields()
        {
            AndromedaObjectFieldCollection children = new AndromedaObjectFieldCollection();
            children.AddRange(base.GetAllFields());
            foreach (AndromedaSource includedSource in includedSources)
            {
                children.AddRange(includedSource.GetAllFields());
            }
            return children;
        }

        public override AndromedaObjectMethodCollection GetAllMethods()
        {
            AndromedaObjectMethodCollection children = new AndromedaObjectMethodCollection();
            children.AddRange(base.GetAllMethods());
            foreach (AndromedaSource includedSource in includedSources)
            {
                children.AddRange(includedSource.GetAllMethods());
            }
            return children;
        }

        public override AndromedaObjectPropertyCollection GetAllProperties()
        {
            AndromedaObjectPropertyCollection children = new AndromedaObjectPropertyCollection();
            children.AddRange(base.GetAllProperties());
            foreach (AndromedaSource includedSource in includedSources)
            {
                children.AddRange(includedSource.GetAllProperties());
            }
            return children;
        }

        public override AndromedaObjectStructCollection GetAllStructs()
        {
            AndromedaObjectStructCollection children = new AndromedaObjectStructCollection();
            children.AddRange(base.GetAllStructs());
            foreach (AndromedaSource includedSource in includedSources)
            {
                children.AddRange(includedSource.GetAllStructs());
            }
            return children;
        }

        public AndromedaSource(string name, AndromedaSourceType type, int inclusionType, string path)
        {
            Name = name;
            Type = type;
            InclusionType = inclusionType;
            Path = path;
        }
    }
}
